Connect package using Python
settings.json
that accompanies script sample. Script runs as c:\python-3.6.3\python copy.py
settings.json
{
"name": "Python script example. Expects Python runtime pre-installed.",
"dev_id": "efi.jobflow",
"description": "This is sample Connect package using Python",
"script": "copy.py",
"email": "[email protected]",
"url": "http://efi.com/fieryjobflow",
"params": {
"RUNTIME": "C:\\python-3.6.3\\python.exe"
}
}
copy.py
#!/usr/bin/python
import sys
print ("script name: ", sys.argv[0])
print ("number of arguments: ", len(sys.argv))
print ("arguments: " , str(sys.argv))
import os
import shutil
source = sys.argv[1]
target = sys.argv[2]
print ("source: ", source)
print ("target: ", target)
# adding exception handling
try:
shutil.copy(source, target)
print("File copy successful to copy file. %s",sys.argv[1] )
except IOError as e:
print("Unable to copy file. %s" % e)
except:
print("Unexpected error:", sys.exc_info())
Alternative settings.json
when Connect Package has Python bundled.
{
"name": "Python script example. Python runtime is bundled",
"dev_id": "efi.jobflow",
"description": "This is sample Connect package using Python",
"script": "copy.py",
"email": "[email protected]",
"url": "http://efi.com/fieryjobflow",
"params": {
"RELATIVE-RUNTIME": "\\python-3.6.3\\python.exe"
}
}